﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using MyMES.Domain.zmc;
using MyMES.Error;
using MyMES.Writer.API.Application.Commends.Enterprises;

namespace MyMES.Writer.API.Controllers.Enterprises
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class EnterpriseController : ControllerBase
    {
        private readonly IMediator mediator;

        public EnterpriseController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 添加企业
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<Enterprise>> CreateEnterprises(CreateEnterprisesCommends request, CancellationToken cancellationToken)
        {
            return await mediator.Send(request, cancellationToken);
        }
    }
}
